package woaini.wind.ai.controller;

import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSONPath;
import lombok.experimental.UtilityClass;

@UtilityClass
public class OpenAgents {

  public static final String OPEN_AGENT_URL = "http://10.8.0.70:52025/api/chat";

  public String chat(String userId,String question) {

    String body = STR."""
      {
          "userId":"\{userId}",
          "message": "\{question}"
      }
      """;
    String response = HttpRequest.post(OPEN_AGENT_URL).body(body).execute().body();
    return (String) JSONPath.eval(response, "$.content");
  }
}
